<template>
  <div class="app-container" id="appContainer">
    <el-row :gutter="20">
      <el-col :span="8">
        <el-card class="box-card">
          <template v-slot:header>
            <div class="clearfix">
              <span>个人信息</span>
            </div>
          </template>
          <div>
            <div class="img-center">
               <Avatar :user="currentUser"/>
            </div>
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                <div class="pull-left">
                  <svg-icon name="user" />
                  <span>用户名称：</span>
                </div>
                <div class="pull-right">
                  {{ currentUser && currentUser.username }}
                </div>
              </li>
              <li class="list-group-item">
                <div class="pull-left">
                  <svg-icon name="phone" />
                  <span>手机号码：</span>
                </div>

                <div class="pull-right">
                  {{ currentUser && currentUser.phone }}
                </div>
              </li>
              <li class="list-group-item">
                <div class="pull-left">
                  <svg-icon name="email" />
                  <span>用户邮箱：</span>
                </div>
                <div class="pull-right">
                  {{ currentUser && currentUser.email }}
                </div>
              </li>
              <li class="list-group-item">
                <div class="pull-left">
                  <svg-icon name="peoples" />
                  <span>角色：</span>
                </div>
                <div class="pull-right">
                  {{ currentUser && currentUser.roles }}
                </div>
              </li>
              <li class="list-group-item">
                <div class="pull-left">
                  <svg-icon name="date" />
                  <span>创建日期：</span>
                </div>
                <div class="pull-right">
                  {{
                    currentUser &&
                    dayjs(currentUser.createTime).format("YYYY-MM-DD HH:mm:ss")
                  }}
                </div>
              </li>
            </ul>
          </div>
        </el-card>
      </el-col>
      <el-col :span="16">
        <el-card>
          <template v-slot:header>
            <div class="clearfix">
              <span>基本资料</span>
            </div>
          </template>
          <el-tabs v-model="activeTab">
            <el-tab-pane label="基本资料" name="first">
              <user-info :user="currentUser" />
            </el-tab-pane>
            <el-tab-pane label="修改密码" name="second">
              <reset-pwd :user="currentUser" />
            </el-tab-pane>
          </el-tabs>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import dayjs from "dayjs";
import UserInfo from "./userInfo.vue";
import ResetPwd from "./resetPwd.vue";
import Avatar from './avatar.vue';
import { usePermissStore } from "@/store/permiss";

const permiss = usePermissStore();
const currentUser: any = permiss.getCurrentUser();
const activeTab = ref("first");

</script>

<style  lang="less">
.app-container {
  padding: 25px;
  font-size: 13px;
}
#appContainer {
  .box-card {
  height: 400px;
  }
  .el-card__body {
    height: 300px;
    text-align: left;
  }
  .el-tabs {
    height: 100%;
  }
  .el-card.is-always-shadow {
    box-shadow: var(--el-box-shadow-light);
    height: 100%;
  }
  .el-tabs__content {
    height: calc(100% - 45px);
  }
  .list-group{
    margin-top: 10px;
  }
  .list-group-item {
    width: 100%;
    text-align: left;
    min-height: 25px;
    line-height: 25px;
    display: flex;
    .pull-left {
      width: 110px;
      overflow: hidden;
      display: flex;
      align-items: center;
      span {
        text-indent: 5px;
      }
    }
    .pull-right {
      display: flex;
      align-items: center;
      width: 200px;
      line-height: 20px;
      overflow-x: hidden;
      word-wrap: break-word;
      word-break: keep-all;
    }
  }

  .clearfix {
    text-align: left;
  }
  .img-center{
    display: flex;
    justify-content: center;
  }
}
</style>